In this section, we’ll explore how Camel is integrating with the Model Context Protocol to create a more powerful and flexible agent framework. Here’s what we’ll cover:
Agent using MCP tools
Export Camel existing tools as MCP servers
MCP search toolkits/ MCP search agents
Export Camel agents as MCP servers
Future plans
Let’s dive into each of these areas to understand how Camel is embracing the MCP ecosystem.
Hands-on with Camel Agents and Tools
from camel.toolkits import FunctionTooldef my_weird_add(a: int, b: int) ->int:r"""Adds two numbers and includes a constant offset. Args: a (int): The first number to be added. b (int): The second number to be added. Returns: integer: The sum of the two numbers plus 7. """return a + b +7agent = ChatAgent( tools=[FunctionTool(my_weird_add)])response = agent.step("What is 15+15")print(response.msgs[0].content)
The result of 15 + 15, using a special calculation method, is 37.
Hands-on with Camel Agents using MCP Servers (1/2)
import asynciofrom camel.toolkits.mcp_toolkit import MCPToolkit, MCPClientasyncdef run_time_example():# Initialize the MCPToolkit with your configuration file mcp_toolkit = MCPToolkit(config_path="config/time.json")# Connect to all configured MCP serversawait mcp_toolkit.connect() camel_agent = ChatAgent( model=model, tools=[*mcp_toolkit.get_tools()], ) response =await camel_agent.astep("What time is it now?")print(response.msgs[0].content)print(response.info['tool_calls'])# Disconnect from all serversawait mcp_toolkit.disconnect()await run_time_example()
The current local time in Riyadh is 15:57 (3:57 PM).
[ToolCallingRecord(tool_name='get_current_time', args={'timezone': 'Asia/Riyadh'}, result='{\n "timezone": "Asia/Riyadh",\n "datetime": "2025-05-01T15:57:59+03:00",\n "is_dst": false\n}', tool_call_id='toolu_01Gwdy3Ppzf2z42t6YL7n7cE')]
# arxiv_toolkit_server.pyimport argparseimport sysfrom camel.toolkits import ArxivToolkitif__name__=="__main__": parser = argparse.ArgumentParser( description="Run Arxiv Toolkit in MCP server mode.", usage=f"python {sys.argv[0]} [--mode MODE]", ) parser.add_argument("--mode", choices=["stdio", "sse"], default="stdio",help="MCP server mode (default: 'stdio')", ) parser.add_argument("--timeout",type=float, default=None,help="Timeout for the MCP server (default: None)", ) args = parser.parse_args() toolkit = ArxivToolkit(timeout=args.timeout)# Run the toolkit as an MCP server toolkit.mcp.run(args.mode)
search_toolkit = PulseMCPSearchToolkit()search_toolkit.search_mcp_servers( query="Slack", package_registry="npm", # Only search for servers registered in npm top_k=1,)
{ "name": "Slack", "url": "https://www.pulsemcp.com/servers/slack", "external_url": null, "short_description": "Send messages, manage channels, and access workspace history.", "source_code_url": "https://github.com/modelcontextprotocol/servers/tree/HEAD/src/slack", "github_stars": 41847, "package_registry": "npm", "package_name": "@modelcontextprotocol/server-slack", "package_download_count": 188989, "EXPERIMENTAL_ai_generated_description": "This Slack MCP Server, developed by the Anthropic team, provides a robust interface for language models to interact with Slack workspaces. It enables AI agents to perform a wide range of Slack-specific tasks including listing channels, posting messages, replying to threads, adding reactions, retrieving channel history, and accessing user information. The implementation distinguishes itself by offering comprehensive Slack API integration, making it ideal for AI-driven workplace communication and automation. By leveraging Slack's Bot User OAuth Tokens, it ensures secure and authorized access to workspace data. This tool is particularly powerful for AI assistants designed to enhance team collaboration, automate routine communication tasks, and provide intelligent insights from Slack conversations."}
from camel.agents import MCPAgent, MCPRegistryConfig, MCPRegistryType smithery_config = MCPRegistryConfig(type=MCPRegistryType.SMITHERY, api_key=os.getenv("SMITHERY_API_KEY"))# Create MCPAgent with registry configurationsagent = MCPAgent( model=model, registry_configs=[smithery_config])asyncwith agent: response =await agent.astep(message)print(f"\nResponse from {message}:")print(response.msgs[0].content)
Example 1 (Search)
message = “What MCP tools can I use for connecting to Gmail?”
"""Response from What MCP tools can I use for connecting to Gmail?: I found several MCP tools that can connect to Gmail. Here are the options: 1. **Google Workspace Server** (@rishipradeep-think41/gsuite-mcp) - Manage emails and calendar events through Gmail and Calendar APIs - [Configure here](https://smithery.ai/server/@rishipradeep-think41/gsuite-mcp/config) 2. **VeyraX MCP** (@VeyraX/veyrax-mcp) - Connects to 70+ tools including Gmail and Calendar - [Configure here](https://smithery.ai/server/@VeyraX/veyrax-mcp/config) 3. **Google Workspace MCP Server** (google-workspace-server) - Interact with Gmail and Calendar APIs - [Configure here](https://smithery.ai/server/google-workspace-server/config) 4. **Headless Gmail Server** (@baryhuang/mcp-headless-gmail) - Access and send emails through Gmail without local credential setup - [Configure here](https://smithery.ai/server/@baryhuang/mcp-headless-gmail/config) 5. **Google Workspace Server** (@rishipradeep-think41/gmail-backupmcp) - Another option for managing Gmail and Calendar Each of these tools requires configuration before it can be used. You'll need to click on one of the configuration links above to set up the tool with your Gmail credentials. Once you've completed the configuration, let me know which tool you've chosen, and I can help you use it to connect to your Gmail account."""
Example 2 (Search + Execution)
May require configuration on the MCP registry, in this case, Smithery.
message = “Use Brave MCP search tools to find information about Camel-AI.org.”
"""Response from Use Brave MCP search tools to search info about Camel-AI.org.: # CAMEL-AI.org: Information and Purpose Based on my search results, here's what I found about CAMEL-AI.org: ## Organization Overview CAMEL-AI.org is the first LLM (Large Language Model) multi-agent framework and an open-source community. The name CAMEL stands for "Communicative Agents for Mind Exploration of Large Language Model Society." ## Core Purpose The organization is dedicated to "Finding the Scaling Law of Agents" - this appears to be their primary research mission, focusing on understanding how agent-based AI systems scale and develop. ## Research Focus CAMEL-AI is a research-driven organization that explores: - Scalable techniques for autonomous cooperation among communicative agents - Multi-agent frameworks for AI systems - Data generation for AI training - AI society simulations ## Community and Collaboration - They maintain an active open-source community - They invite contributors and collaborators through platforms like Slack and Discord - The organization has a research collaboration questionnaire for those interested in building or researching environments for LLM-based agents ## Technical Resources - Their code is available on GitHub (github.com/camel-ai) with 18 repositories - They provide documentation for developers and researchers at docs.camel-ai.org - They offer tools and cookbooks for working with their agent framework ## Website and Online Presence - Main website: https://www.camel-ai.org/ - GitHub: https://github.com/camel-ai - Documentation: https://docs.camel-ai.org/ The organization appears to be at the forefront of research on multi-agent AI systems, focusing on how these systems can cooperate autonomously and scale effectively."""
# Create a default chat agent - customize as neededchat_agent = ChatAgent()chat_agent_description ="A general-purpose assistant that can answer questions and help with various tasks."reasoning_agent = ChatAgent( model=ModelFactory.create( model_platform=ModelPlatformType.OPENAI, model_type="gpt-4o-mini", ))reasoning_agent_description ="A specialized assistant focused on logical reasoning and problem-solving."# Create another agent for searching the websearch_agent = ChatAgent( model=ModelFactory.create( model_platform=ModelPlatformType.OPENAI, model_type="gpt-4o", ), tools=[FunctionTool(SearchToolkit().search_brave)],)search_agent_description ="A research assistant capable of retrieving information from the web."# Provide a list of agents with namesagents_dict = {"general": chat_agent,"search": search_agent,"reasoning": reasoning_agent,}# Provide descriptions for each agentdescription_dict = {"general": chat_agent_description,"search": search_agent_description,"reasoning": reasoning_agent_description,}